package org.jcc.servlet.encoding.page;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/encoding/page/wrongHeaderRightMeta")
public class EncodingWrongHeaderRightMeta extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setHeader("Content-type", "text/html; charset=gbk");
		ServletOutputStream os = response.getOutputStream();
		String meta = "<head><meta charset=\"utf-8\"></head>";
		os.write((meta + "编码与 header 冲突，与 meta 一致，meta 优先级低，结果乱码。").getBytes("utf-8"));
	}
}
